package com.jt.sys.controller;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jt.common.vo.JsonResult;
import com.jt.common.vo.PageObject;
import com.jt.sys.entity.SysRole;
import com.jt.sys.service.SysRoleService;
@Controller
@RequestMapping("/role/")
public class SysRoleController {
	@Autowired
	private SysRoleService sysRoleService;
	@RequestMapping("doRoleListUI")
	public String doRoleListUI(){
		return "sys/role_list";
	}
	@RequiresPermissions("sys:role:add")
	@RequestMapping("doRoleSaveEditUI")
	public String doRoleSaveEditUI(){
		return "sys/role_edit";
	}
	@RequiresPermissions("sys:role:update")
	@RequestMapping("doRoleUpdateEditUI")
	public String doRoleUpdateEditUI(){
		return "sys/role_edit";
	}
	@RequestMapping("doFindPageObjects")
	@ResponseBody
	@RequiresPermissions("sys:role:view")
	public JsonResult doFindPageObjects(String name,Integer pageCurrent){
		PageObject<SysRole> pageObject = sysRoleService.findPageObjects(name, pageCurrent);
		return new JsonResult(pageObject,"find ok");
	}
	@RequestMapping("doDeleteObject")
	@ResponseBody
	@RequiresPermissions("sys:role:del")
	public JsonResult doDeleteObject(Integer id){
		sysRoleService.deleteObject(id);
		return new JsonResult("delete ok");
	}
	@RequestMapping("doSaveObject")
	@ResponseBody
	public JsonResult doSaveObject(SysRole entity,Integer[] menuIds){
		sysRoleService.saveObject(entity, menuIds);
		return new JsonResult("save ok");
	}
	@RequestMapping("doFindObjectById")
	@ResponseBody
	public JsonResult doFindObjectById(Integer id){
		Map<String, Object> map = sysRoleService.findObjectById(id);
		return new JsonResult(map);
	}
	@RequestMapping("doUpdateObject")
	@ResponseBody
	public JsonResult doUpdateObject(SysRole entity,Integer[] menuIds){
		sysRoleService.updateObject(entity, menuIds);
		return new JsonResult("update ok");
	}
}
